import {RouteRecordRaw} from 'vue-router';
import {Layout} from '@/router/constant';
import {DashboardOutlined} from '@vicons/antd';
import {renderIcon} from '@/utils';

const routeName = 'statistics';

/**
 * @param name 路由名称, 必须设置,且不能重名
 * @param meta 路由元信息（路由附带扩展信息）
 * @param redirect 重定向地址, 访问这个路由时,自定进行重定向
 * @param meta.disabled 禁用整个菜单
 * @param meta.title 菜单名称
 * @param meta.icon 菜单图标
 * @param meta.keepAlive 缓存该路由
 * @param meta.sort 排序越小越排前
 * */
const routes: Array<RouteRecordRaw> = [
  {
    path: '/statistics',
    name: routeName,
    redirect: '/statistics/sheet',
    component: Layout,
    meta: {
      title: '销售统计数据',
      icon: renderIcon(DashboardOutlined),
      permissions: ['statistics'],
      sort: 1,
    },
    children: [
      {
        path: 'sheet',
        name: `${routeName}_sheet`,
        meta: {
          title: '出货统计表',
          keepAlive: true,
        },
        component: () => import('@/views/statistics/sheet.vue'),
      },
      {
        path: 'column_chart',
        name: `${routeName}_column`,
        meta: {
          title: '时间柱形图',
          keepAlive: true,
        },
        component: () => import('@/views/statistics/column_chart.vue'),
      },
      {
        path: 'trend_chart',
        name: `${routeName}_trend`,
        meta: {
          title: '趋势曲线图',
          keepAlive: true,
        },
        component: () => import('@/views/statistics/trend_chart.vue'),
      },
      {
        path: 'distribution_diagram',
        name: `${routeName}_distribution`,
        meta: {
          title: '地区分布图',
          keepAlive: true,
        },
        component: () => import('@/views/statistics/distribution_diagram.vue'),
      },
    ],
  },
];

export default routes;